package com.linedata.acq.test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.StringTokenizer;

import oracle.forms.jdapi.Block;
import oracle.forms.jdapi.Canvas;
import oracle.forms.jdapi.FormModule;
import oracle.forms.jdapi.Graphics;
import oracle.forms.jdapi.Item;
import oracle.forms.jdapi.Jdapi;
import oracle.forms.jdapi.JdapiIterator;
import oracle.forms.jdapi.JdapiModule;
import oracle.forms.jdapi.LOV;
import oracle.forms.jdapi.LOVColumnMapping;
import oracle.forms.jdapi.ProgramUnit;
import oracle.forms.jdapi.RecordGroup;
import oracle.forms.jdapi.Trigger;
import oracle.forms.jdapi.Window;

public class Services {
	String					fmb;
	private BufferedWriter	tra;
	private Object			text;

	public static void main(String[] args) {
		try {
			Initial("C:\\Documents and Settings\\mgmenaouar\\Bureau\\jdapiutil\\JDAPIUTIL.fmb");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// ******************** GRILLE *********************
	public static void Initial(String fmb) throws IOException {

		String err = null;
		Jdapi.setFailSubclassLoad(true);
		Jdapi.setFailLibraryLoad(true);
		JdapiModule.openModule(fmb);
		try {
			err = Nom_Block_Base(fmb);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		System.out.println(err);

	}

	public static String Nom_Block_Base(String fmb) throws IOException, ClassNotFoundException, InstantiationException,
			IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			if (!block.getDMLDataName().equals(block.getName()) && !block.getDMLDataName().isEmpty()) {
				erreur = erreur + "     - " + block.getName() + "\n";
			}
		}
		return (erreur);
	}

	public String Nom_Canevas(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		String erreur = "";
		boolean trouve = false;
		try {

			Canvas cnv;
			for (JdapiIterator cnvss = grille.getCanvases(); cnvss.hasNext();) {
				cnv = (Canvas) cnvss.next();
				if (!cnv.getName().startsWith("PAGE_") && !cnv.getName().startsWith("FOOTER_PAGE")
						&& !cnv.getName().equals("TOOLBAR") && cnv.isSubclassed()
						&& cnv.getSubclassParent().getName().contains("IESO$CANVAS")) {
					erreur = erreur + "     - " + cnv.getName() + "\n";
				}
				if (cnv.getName().equals("PAGE_1")) {
					trouve = true;
				}
			}
			if (!trouve) {
				erreur = erreur + "     - " + " PAGE_1 (Manquant)" + "\n";
			}
		}

		catch (Throwable e) {
			System.err.println("erreur Lancement Nom_Canevas" + e);
		}
		return (erreur);
	}

	public String Nom_Champ_Max(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getName().length() > 25) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Nom_Windows(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		Window wndw;
		String erreur = "";
		for (JdapiIterator wndws = grille.getWindows(); wndws.hasNext();) {
			wndw = (Window) wndws.next();
			if (!wndw.getName().startsWith("PAGE_")) {
				erreur = erreur + "     - " + wndw.getName() + "\n";
			}
		}
		return (erreur);
	}

	public String Nom_RecordGroup(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		RecordGroup rgr;
		String erreur = "";
		String erreur_recgrp = "";
		boolean trouve = false;
		for (JdapiIterator rgrs = grille.getRecordGroups(); rgrs.hasNext();) {
			rgr = (RecordGroup) rgrs.next();
			if (rgr.getName().contains("_LOV")) {
				String Verif = rgr.getName().toUpperCase().substring(0, rgr.getName().indexOf("_LOV"));
				trouve = false;
				// Verifier si le nom correspond
				JdapiIterator blocks = grille.getBlocks();
				while (blocks.hasNext()) {
					Block block = (Block) blocks.next();
					for (JdapiIterator items = block.getItems(); items.hasNext();) {
						Item itm = (Item) items.next();
						if (Verif.equalsIgnoreCase(block.getName() + "_" + itm.getName())) {
							trouve = true;
						}
					}
				}

				if (!trouve) {
					erreur = erreur + rgr.getName() + ", ";
				}
			} // fin if
			if (!rgr.getName().contains("_LOV")) {
				erreur = erreur + "     - " + rgr.getName() + "\n";
			}
			//
		}
		return (erreur);
	}

	public String Nom_Lov(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		String erreur = "";
		LOV lov;
		boolean trouve = false;
		for (JdapiIterator lovs = grille.getLOVs(); lovs.hasNext();) {
			lov = (LOV) lovs.next();
			if (lov.getName().contains("_LOV")) {
				String Verif = lov.getName().toUpperCase().substring(0, lov.getName().indexOf("_LOV"));
				trouve = false;
				// Verifier si le nom correspond
				JdapiIterator blocks = grille.getBlocks();
				while (blocks.hasNext()) {
					Block block = (Block) blocks.next();
					for (JdapiIterator items = block.getItems(); items.hasNext();) {
						Item itm = (Item) items.next();
						if (Verif.equalsIgnoreCase(block.getName() + "_" + itm.getName())) {
							trouve = true;

						}

					}
				}

				if (!trouve) {
					erreur = erreur + "     - " + lov.getName() + "\n ";
				}
			} // fin if
			if (!lov.getName().contains("_LOV")) {
				erreur = erreur + "     - " + lov.getName() + "\n";
			}
			//
		}
		return (erreur);
	}

	public String Nom_Bouton_Lov(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.getItemType() == 7 && itm.isSubclassed()
						&& itm.getSubclassParent().getName().startsWith("IESO$LOV_BUT")
						&& !itm.getName().startsWith("LOV_")) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Nom_Bouton_Edit(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.getItemType() == 7 && itm.isSubclassed()
						&& itm.getSubclassParent().getName().startsWith("IES$BUTTON_EDIT")
						&& !itm.getName().startsWith("EDIT_")) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	} // Fin InitGrille

	public String Nom_Bouton(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			if (!block.getName().equals("FOOTER") && !block.getName().equals("TOOLBAR")
					&& !block.getName().equals("TITRE_CTRL") && !block.getName().equals("DICREF")) {
				for (JdapiIterator items = block.getItems(); items.hasNext();) {
					Item itm = (Item) items.next();
					if (itm.getItemType() == 7 && !itm.getName().startsWith("LOV_")
							&& !itm.getName().startsWith("EDIT_") && !itm.getName().startsWith("PB_")) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
				}
			}
		}
		return (erreur);
	}

	public String Nom_Titre_Block(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";

		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			if (block.getName().toUpperCase().equals("TITRE_CTRL")) {
				for (JdapiIterator items = block.getItems(); items.hasNext();) {
					Item itm = (Item) items.next();
					if (!itm.getName().toUpperCase().endsWith("_WIN") && !itm.getName().toUpperCase().endsWith("_TAB")
							&& itm.getName().toUpperCase().contains("_TITRE")) {
						// nom block a rechercher
						String recherche = itm.getName().substring(0, itm.getName().toUpperCase().indexOf("_TITRE"));
						boolean trouve = false;
						JdapiIterator new_blocks = grille.getBlocks();
						while (new_blocks.hasNext()) {
							Block new_block = (Block) new_blocks.next();
							if (new_block.getName().toUpperCase().equals(recherche)) {
								trouve = true;
							}
						}
						if (!trouve || !itm.getName().toUpperCase().contains("_TITRE")) {
							erreur = erreur + "     - " + itm.getName() + "\n";
						}
						// erreur = erreur +block.getName()+"."+ itm.getName()+
						// " ,";
					}
				}
			}
		}
		return (erreur);
	}

	public String Nom_Titre_Fenetre(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			if (block.getName().toUpperCase().equals("TITRE_CTRL")) {
				for (JdapiIterator items = block.getItems(); items.hasNext();) {
					Item itm = (Item) items.next();
					if (!itm.getName().toUpperCase().endsWith("TITRE_TAB")
							&& itm.getName().toUpperCase().endsWith("_TITRE_WIN")) {
						// nom block a rechercher
						String recherche = itm.getName()
								.substring(0, itm.getName().toUpperCase().indexOf("_TITRE_WIN"));
						boolean trouve = false;
						JdapiIterator new_blocks = grille.getBlocks();
						while (new_blocks.hasNext()) {
							Block new_block = (Block) new_blocks.next();
							if (new_block.getName().toUpperCase().equals(recherche)) {
								trouve = true;
							}
						}
						if (!trouve || !itm.getName().toUpperCase().contains("_TITRE_WIN")) {
							erreur = erreur + "     - " + itm.getName() + "\n";
						}
						// erreur = erreur +block.getName()+"."+ itm.getName()+
						// " ,";
					}
				}
			}
		}
		return (erreur);
	}

	public String Nom_Titre_Onglet(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			if (block.getName().toUpperCase().equals("TITRE_CTRL")) {
				for (JdapiIterator items = block.getItems(); items.hasNext();) {
					Item itm = (Item) items.next();
					if (itm.getName().toUpperCase().endsWith("TITRE_TAB")) {
						// nom block a rechercher
						String recherche = itm.getName()
								.substring(0, itm.getName().toUpperCase().indexOf("_TITRE_TAB"));
						boolean trouve = false;
						JdapiIterator new_blocks = grille.getBlocks();
						while (new_blocks.hasNext()) {
							Block new_block = (Block) new_blocks.next();
							if (new_block.getName().toUpperCase().equals(recherche)) {
								trouve = true;
							}
						}
						if (!trouve || !itm.getName().toUpperCase().endsWith("_TITRE_TAB")) {
							erreur = erreur + "     - " + itm.getName() + "\n";
						}
						// erreur = erreur +block.getName()+"."+ itm.getName()+
						// " ,";
					}
				}
			}
		}
		return (erreur);
	}

	public String Nom_Frame(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		String erreur = "";
		try {
			FormModule grille = FormModule.open(fmb);
			Canvas cnv;
			Graphics grph;
			for (JdapiIterator cnvss = grille.getCanvases(); cnvss.hasNext();) {
				cnv = (Canvas) cnvss.next();
				for (JdapiIterator grphs = cnv.getGraphicses(); grphs.hasNext();) {
					grph = (Graphics) grphs.next();
					if (!grph.getName().substring(0, 4).equals("GRPH")) {
						erreur = erreur + "     - " + grph.getName() + "\n";
					}
				}
			}
		} catch (Throwable e) {
			System.err.println("erreur Lancement Nom_Frames" + e);
		}
		return (erreur);
	}

	public String Ordre_Sql_Triggers(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		// Controle form trigger
		JdapiIterator triggers_f = grille.getTriggers();
		String erreur_f = "";
		while (triggers_f.hasNext()) {
			Trigger trigger_f = (Trigger) triggers_f.next();
			if (trigger_f.getTriggerText().toUpperCase().contains(" SELECT ")
					|| trigger_f.getTriggerText().toUpperCase().contains(" INSERT ")
					|| trigger_f.getTriggerText().toUpperCase().contains(" DELETE ")
					|| trigger_f.getTriggerText().toUpperCase().contains(" UPDATE ")
					|| trigger_f.getTriggerText().toUpperCase().contains(" SELECT ")) {
				erreur_f = erreur_f + trigger_f.getName() + ", ";
			}
		}
		if (!erreur_f.isEmpty()) {
			erreur = erreur + "\n" + "                   - Triggers sur la grille : ";
			erreur = erreur + erreur_f;
		}
		// Controle blocks
		String erreur_block = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			JdapiIterator triggers_b = block.getTriggers();
			while (triggers_b.hasNext()) {
				Trigger trigger_b = (Trigger) triggers_b.next();
				if (trigger_b.getTriggerText().toUpperCase().contains(" SELECT ")
						|| trigger_b.getTriggerText().toUpperCase().contains(" INSERT ")
						|| trigger_b.getTriggerText().toUpperCase().contains(" DELETE ")
						|| trigger_b.getTriggerText().toUpperCase().contains(" UPDATE ")
						|| trigger_b.getTriggerText().toUpperCase().contains(" SELECT ")) {
					erreur_block = erreur_block + block.getName() + "." + trigger_b.getName() + ", ";
				}

			}
		}
		if (!erreur_block.isEmpty()) {
			erreur = erreur + "\n" + "                   - Triggers sur les Blocks : ";
			erreur = erreur + erreur_block;
		}

		// controle item

		String erreur_itm = "";
		JdapiIterator blocks1 = grille.getBlocks();
		while (blocks1.hasNext()) {
			Block block1 = (Block) blocks1.next();
			for (JdapiIterator items = block1.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				JdapiIterator triggers_c = itm.getTriggers();
				while (triggers_c.hasNext()) {
					Trigger trigger_c = (Trigger) triggers_c.next();
					if (trigger_c.getTriggerText().toUpperCase().contains(" SELECT ")
							|| trigger_c.getTriggerText().toUpperCase().contains(" INSERT ")
							|| trigger_c.getTriggerText().toUpperCase().contains(" DELETE ")
							|| trigger_c.getTriggerText().toUpperCase().contains(" UPDATE ")
							|| trigger_c.getTriggerText().toUpperCase().contains(" SELECT ")) {
						erreur_itm = erreur_itm + block1.getName() + "." + itm.getName() + "." + trigger_c.getName()
								+ ", ";
					}

				}
			}
		}
		if (!erreur_itm.isEmpty()) {
			erreur = erreur + "\n" + "                   - Triggers sur les Item : ";
			erreur = erreur + erreur_itm;
		}

		return (erreur);
	}

	public String Commentaires(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		// Controle blocks
		String erreur_block = "";
		String plsql = "";
		String sligne = "";
		boolean trouve = false;
		String plsql_c = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			JdapiIterator triggers_b = block.getTriggers();
			while (triggers_b.hasNext()) {
				Trigger trigger_b = (Trigger) triggers_b.next();
				plsql = trigger_b.getTriggerText();
				StringTokenizer ligne = new StringTokenizer(plsql, ";");
				while (ligne.hasMoreTokens() && !trouve) {
					sligne = ligne.nextToken().replaceAll(" ", "");
					if (sligne.startsWith("/*")) {
						trouve = true;
					}
				}
				if (trouve) {
					erreur = erreur + "     - " + block.getName() + "." + trigger_b.getName() + "\n";
				}
			}

		}
		// controle item

		String erreur_itm = "";
		JdapiIterator blocks1 = grille.getBlocks();
		while (blocks1.hasNext()) {
			Block block1 = (Block) blocks1.next();
			for (JdapiIterator items = block1.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				JdapiIterator triggers_c = itm.getTriggers();
				while (triggers_c.hasNext()) {
					Trigger trigger_c = (Trigger) triggers_c.next();
					plsql_c = trigger_c.getTriggerText();
					StringTokenizer ligne = new StringTokenizer(plsql_c, ";");
					while (ligne.hasMoreTokens() && !trouve) {
						sligne = ligne.nextToken();
						if (sligne.startsWith("/*")) {
							trouve = true;
						}
					}
					if (trouve) {
						erreur = erreur + "     - " + block1.getName() + "." + itm.getName() + "."
								+ trigger_c.getName() + "\n";
					}

				}
			}
		}
		ProgramUnit progunit;
		String plsql_p = "";
		// ****** procedure ****
		for (JdapiIterator progunits = grille.getProgramUnits(); progunits.hasNext();) {
			progunit = (ProgramUnit) progunits.next();
			plsql_p = progunit.getProgramUnitText();
			trouve = false;

			StringTokenizer ligne = new StringTokenizer(plsql_p, ";");
			while (ligne.hasMoreTokens() && !trouve) {
				sligne = ligne.nextToken();
				if (sligne.startsWith("/*")) {
					trouve = true;
				}
			}
			if (trouve && !progunit.getName().startsWith("IE_")) {
				erreur = erreur + "     - " + progunit.getName() + "\n";
			}
		}

		return (erreur);
	}

	public String Commentaires1(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		// Controle blocks
		String erreur_block = "";
		String plsql = "";
		String sligne = "";
		boolean trouve = false;
		String plsql_c = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			JdapiIterator triggers_b = block.getTriggers();
			while (triggers_b.hasNext()) {
				Trigger trigger_b = (Trigger) triggers_b.next();
				plsql = trigger_b.getTriggerText();
				StringTokenizer ligne = new StringTokenizer(plsql, ";");
				while (ligne.hasMoreTokens() && !trouve) {
					sligne = ligne.nextToken().replaceAll(" ", "").replaceAll("\n", "").replaceAll("\t", "");
					if (!sligne.startsWith("--") && !sligne.startsWith("/*") && !sligne.startsWith("*")
							&& sligne.contains("--") && !sligne.toUpperCase().startsWith("BEGIN")
							&& !sligne.toUpperCase().startsWith("IF") && !sligne.toUpperCase().startsWith("ELSE")
							&& !sligne.toUpperCase().startsWith("PROCEDURE")
							&& !sligne.toUpperCase().startsWith("FUNCTION")) {

						trouve = true;
					}
				}
				if (trouve) {
					erreur = erreur + "     - " + block.getName() + "." + trigger_b.getName() + "\n";
				}
			}

		}
		// controle item

		String erreur_itm = "";
		JdapiIterator blocks1 = grille.getBlocks();
		while (blocks1.hasNext()) {
			Block block1 = (Block) blocks1.next();
			for (JdapiIterator items = block1.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				JdapiIterator triggers_c = itm.getTriggers();
				while (triggers_c.hasNext()) {
					Trigger trigger_c = (Trigger) triggers_c.next();
					plsql_c = trigger_c.getTriggerText().replaceAll(" ", "").replaceAll("\n", "").replaceAll("\t", "");
					StringTokenizer ligne = new StringTokenizer(plsql_c, ";");
					while (ligne.hasMoreTokens() && !trouve) {
						sligne = ligne.nextToken();
						if (!sligne.startsWith("--") && !sligne.startsWith("/*") && !sligne.startsWith("*")
								&& sligne.contains("--") && !sligne.toUpperCase().startsWith("BEGIN")
								&& !sligne.toUpperCase().startsWith("IF") && !sligne.toUpperCase().startsWith("ELSE")
								&& !sligne.toUpperCase().startsWith("PROCEDURE")
								&& !sligne.toUpperCase().startsWith("FUNCTION")) {
							trouve = true;

						}
					}
					if (trouve) {
						erreur = erreur + "     - " + block1.getName() + "." + itm.getName() + "."
								+ trigger_c.getName() + "\n";
					}

				}
			}
		}
		ProgramUnit progunit;
		String plsql_p = "";
		// ****** procedure ****
		for (JdapiIterator progunits = grille.getProgramUnits(); progunits.hasNext();) {
			progunit = (ProgramUnit) progunits.next();
			plsql_p = progunit.getProgramUnitText();
			trouve = false;

			StringTokenizer ligne = new StringTokenizer(plsql_p, ";");
			while (ligne.hasMoreTokens() && !trouve) {
				sligne = ligne.nextToken().replaceAll(" ", "").replaceAll("\n", "").replaceAll("\t", "");
				if (!sligne.startsWith("--") && !sligne.startsWith("/*") && !sligne.startsWith("*")
						&& sligne.contains("--")

						&& !sligne.toUpperCase().startsWith("BEGIN") && !sligne.toUpperCase().startsWith("IF")
						&& !sligne.toUpperCase().startsWith("ELSE") && !sligne.toUpperCase().startsWith("PROCEDURE")
						&& !sligne.toUpperCase().startsWith("FUNCTION")) {
					trouve = true;

				}
			}
			if (trouve && !progunit.getName().startsWith("IE_")) {
				erreur = erreur + "     - " + progunit.getName() + "\n";
			}
		}

		return (erreur);
	}

	public String Decl_Variables(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		String plsql = "";
		String sligne = "";
		String debut = "";
		int p_declare = 0;
		int p_begin = 0;
		String erreur_block = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			JdapiIterator triggers_b = block.getTriggers();
			while (triggers_b.hasNext()) {
				Trigger trigger_b = (Trigger) triggers_b.next();
				plsql = trigger_b.getTriggerText().toUpperCase();
				if (plsql.contains("DECLARE")) {
					p_declare = plsql.indexOf("DECLARE") + 7;
					p_begin = plsql.indexOf("BEGIN");
					if (p_declare >= 7 && p_begin > 0 && p_begin > p_declare) {
						StringTokenizer ligne = new StringTokenizer(plsql.substring(p_declare, p_begin), ";");
						while (ligne.hasMoreTokens()) {
							sligne = ligne.nextToken().toUpperCase().trim();
							int p_blanc = 0;
							p_blanc = sligne.trim().indexOf(" ");
							if (p_blanc > -1 && !sligne.startsWith("W_") && !sligne.startsWith("CURSOR")
									&& !sligne.startsWith("--") && !sligne.startsWith("/*")) {
								erreur_block = erreur_block + "     - " + block.getName() + " : "
										+ sligne.trim().substring(0, p_blanc) + "\n";
							}
						}
					}// fin if
				}// fin if
			}
		} // fin while block
		if (erreur_block != "") {
			erreur = erreur + " * Block : " + "\n";
			erreur = erreur + erreur_block + "\n";
		}

		// ******************** Trigger champ
		JdapiIterator blocks1 = grille.getBlocks();
		String erreur_itm = "";
		while (blocks1.hasNext()) {
			Block block1 = (Block) blocks1.next();
			for (JdapiIterator items = block1.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				JdapiIterator triggers_c = itm.getTriggers();
				while (triggers_c.hasNext()) {
					Trigger trigger_c = (Trigger) triggers_c.next();
					plsql = trigger_c.getTriggerText().toUpperCase();
					if (plsql.contains("DECLARE")) {
						p_declare = plsql.indexOf("DECLARE") + 7;
						p_begin = plsql.indexOf("BEGIN");
						if (p_declare >= 7 && p_begin > 0 && p_begin > p_declare) {
							StringTokenizer ligne = new StringTokenizer(plsql.substring(p_declare, p_begin), ";");
							while (ligne.hasMoreTokens()) {
								sligne = ligne.nextToken().toUpperCase().trim();
								int p_blanc = 0;
								p_blanc = sligne.trim().indexOf(" ");
								if (p_blanc > -1 && !sligne.startsWith("W_") && !sligne.startsWith("CURSOR")
										&& !sligne.startsWith("--") && !sligne.startsWith("/*")) {
									erreur_itm = erreur_itm + "     - " + block1.getName() + "." + itm.getName()
											+ sligne.trim().substring(0, p_blanc) + "\n";
								}
							}
						}// fin if
					}// fin if
				}
			}
		} // fin while block
		if (erreur_itm != "") {
			erreur = erreur + " * Item : " + "\n";
			erreur = erreur + erreur_itm + "\n";
		}
		ProgramUnit progunit;
		String erreur_prg = "";
		// ************* Controle itmm trigger
		for (JdapiIterator progunits = grille.getProgramUnits(); progunits.hasNext();) {
			progunit = (ProgramUnit) progunits.next();
			plsql = progunit.getProgramUnitText().toUpperCase();
			if (plsql.contains("DECLARE")) {
				debut = "DECLARE";
			}
			if (plsql.contains("PROCEDURE")) {
				debut = "PROCEDURE";
			}
			if (plsql.contains("FUNCTION")) {
				debut = "FUNCTION";
			}
			if (plsql.contains(debut)) {
				if (debut == "DECLARE") {
					p_declare = plsql.indexOf(debut) + debut.length();
				}
				if (debut == "PROCEDURE" || debut == "FUNCTION") {
					p_declare = plsql.indexOf(" IS ") + 4;
				}
				p_begin = plsql.indexOf("BEGIN");
				if (p_declare >= 7 && p_begin > 0 && p_begin > p_declare) {
					StringTokenizer ligne = new StringTokenizer(plsql.substring(p_declare, p_begin), ";");
					while (ligne.hasMoreTokens()) {
						sligne = ligne.nextToken().toUpperCase().trim();
						int p_blanc = 0;
						p_blanc = sligne.trim().indexOf(" ");
						if (p_blanc > -1 && !sligne.startsWith("W_") && !sligne.startsWith("CURSOR")
								&& !sligne.startsWith("--") && !sligne.startsWith("/*")) {
							erreur_prg = erreur_prg + "     - " + progunit.getName() + "."
									+ sligne.trim().substring(0, p_blanc) + ",";
						}
					}
				}// fin if
			}// fin if
		}
		if (erreur_prg != "") {
			erreur = erreur + " * Procédures : " + "\n";
			erreur = erreur + erreur_prg + "\n";
		}

		return (erreur);
	}

	public String Falg_Query_WVI(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			JdapiIterator triggers = block.getTriggers();
			while (triggers.hasNext()) {
				Trigger trigger = (Trigger) triggers.next();
				if (trigger.getName().contains("WHEN-VALIDATE-ITEM")
						&& !trigger.getTriggerText().toUpperCase().replaceAll(" ", "")
								.contains("IF:GLOBAL.FLAG_QUERY='0'")
						&& !trigger.getTriggerText().toUpperCase().replaceAll(" ", "")
								.contains("IF:GLOBAL.FLAG_QUERY!='1'")) {
					erreur = erreur + block.getName();
				}
			}
			// **** wvi sur les champs
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				JdapiIterator triggers_c = block.getTriggers();
				while (triggers_c.hasNext()) {
					Trigger trigger_c = (Trigger) triggers_c.next();
					if (trigger_c.getName().equals("WHEN-VALIDATE-ITEM")
					// &&
					// !trigger_c.getTriggerText().toUpperCase().replaceAll(" ",
					// "").contains("GLOBAL.FLAG_QUERY")
					// &&
					// !trigger_c.getTriggerText().toUpperCase().replaceAll(" ",
					// "").contains("GLOBAL.FLAG_QUERY")){
					) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
				}
			}
		}
		return (erreur);
	}

	public String Block_MR(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (block.isSubclassed()
						&& block.getSubclassParent().getName().equals("IESO$BLOCK")
						&& itm.isVisible()
						&& !itm.getCanvasName().isEmpty()
						&& (block.getRecordsDisplayCount() > 1 || itm.isSubclassed()
								&& itm.getSubclassParent().getName().endsWith("_MR"))) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Taille_Champ_Base(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException, SQLException {
		String erreur = "";
		String USERNAME = new String("ops$ingenetudes");
		String PASSWORD = new String("galene");
		String ENV = new String("jdbc:oracle:thin:@phobos:1521:" + Env);
		Connection con = null;
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		if (!Env.isEmpty() && !Env.equals("")) { // connexion à la base
			try {
				DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
				con = DriverManager.getConnection(ENV, USERNAME, PASSWORD);
				System.out.println("Connexion etablie");
				while (blocks.hasNext()) {
					Block block = (Block) blocks.next();
					for (JdapiIterator items = block.getItems(); items.hasNext();) {
						Item itm = (Item) items.next();
						if (itm.isVisible() && !itm.getCanvasName().isEmpty()
								&& !block.getQueryDataSourceName().isEmpty() && itm.isDatabaseItem()
								&& itm.getItemType() == 9) {
							// recherche dans la base
							String query = "select DATA_TYPE,nvl(DATA_LENGTH,0),nvl(DATA_PRECISION,0) from all_tab_columns "
									+ " where TABLE_NAME = "
									+ "'"
									+ block.getQueryDataSourceName()
									+ "'"
									+ " and COLUMN_NAME = " + "'" + itm.getName() + "'";
							Statement stmt;
							// System.out.println ("Query ---- >"+query);
							// extraction taille champ dans la base
							try {
								stmt = con.createStatement();
								ResultSet rs = stmt.executeQuery(query);
								ResultSetMetaData rsmd = rs.getMetaData();
								int numberOfColumns = rsmd.getColumnCount();
								int rowCount = 1;
								String ctype = "";
								int l_char = 0, l_num = 0;
								while (rs.next()) {
									// System.out.println("Row " + rowCount +
									// ":  ");
									for (int i = 1; i <= numberOfColumns; i++) {
										if (i == 1) {
											ctype = rs.getString(i);
										}
										if (i == 2) {
											l_char = Integer.parseInt(rs.getString(i));
										}
										if (i == 3) {
											l_num = Integer.parseInt(rs.getString(i));
										}
									}

									rowCount++;
								}
								int l = 0;
								if (ctype.contains("NUMBER")) {
									l = l_num;
								}
								if (ctype.contains("VARCHAR2")) {
									l = l_char;
								}
								// System.err.println("FMB : "+fmb+" ITEM : "+itm.getName()+" Taille dans la base = "+l
								// +" Maxlength = "+itm.getMaximumLength());
								if (l < itm.getMaximumLength() && l != 0) {
									erreur = erreur + "    - " + block.getName() + "." + itm.getName() + "\n";
								}
								stmt.close();
							} catch (SQLException ex) {
								System.err.print("SQLException: ");
								System.err.println(ex.getMessage());
							}
						} // if (!table.isEmpty() && i
					} // fin while block

				} // fin connexion
			} catch (Exception Ecx) {
				System.out.println("Erreur Connexion :   " + Ecx.getMessage());

			}
		}// fin if Env

		return (erreur);
	}

	public String Width_Champ(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			if (!block.getName().equals("FOOTER") && !block.getName().equals("TOOLBAR")
					&& !block.getName().equals("TITRE_CTRL") && !block.getName().equals("DICREF")) {
				for (JdapiIterator items = block.getItems(); items.hasNext();) {
					Item itm = (Item) items.next();
					if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getMaximumLength() == 4
							&& itm.getWidth() != 35) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
					if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getMaximumLength() == 10
							&& itm.getWidth() != 60 && !itm.getSubclassParent().getName().startsWith("IESO$DATE_AFF")
							&& !itm.getSubclassParent().getName().startsWith("IESO$MONTANT")) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
					if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getMaximumLength() == 12
							&& itm.getWidth() != 70) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
					if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.isSubclassed()
							&& itm.getSubclassParent().getName().startsWith("IESO$DATE_AFF") && itm.getWidth() != 55) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
					if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.isSubclassed()
							&& itm.getSubclassParent().getName().startsWith("IESO$MONTANT") && itm.getWidth() != 95) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
					if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getWidth() != 15
							&& itm.getItemType() == 2) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
					if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getMaximumLength() == 30
							&& itm.getWidth() != 130 && itm.getName().toUpperCase().startsWith("LIB")) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
					if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getWidth() != 10
							&& itm.getItemType() == 7
							&& (itm.getName().startsWith("LOV_") || itm.getName().startsWith("EDIT_"))) {
						erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
					}
				}
			}
		}
		return (erreur);
	}

	public String Champ_Base_Required(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException, SQLException {
		String erreur = "";
		String USERNAME = new String("ops$ingenetudes");
		String PASSWORD = new String("galene");
		String ENV = new String("jdbc:oracle:thin:@phobos:1521:" + Env);
		Connection con = null;
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		if (!Env.isEmpty() && !Env.equals("")) { // connexion à la base
			try {
				DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
				con = DriverManager.getConnection(ENV, USERNAME, PASSWORD);
				System.out.println("Connexion etablie");
				while (blocks.hasNext()) {
					Block block = (Block) blocks.next();
					for (JdapiIterator items = block.getItems(); items.hasNext();) {
						Item itm = (Item) items.next();
						if (itm.isVisible() && itm.isEnabled() && !itm.getCanvasName().isEmpty()
								&& !block.getDMLDataName().isEmpty() && itm.isDatabaseItem() && !itm.isRequired()
								&& (itm.isInsertAllowed() || itm.isUpdateAllowed())) {
							// recherche dans la base
							String query = "select nvl(NULLABLE,\'N\') from all_tab_columns " + " where TABLE_NAME = "
									+ "'" + block.getDMLDataName() + "'" + " and COLUMN_NAME = " + "'" + itm.getName()
									+ "'";
							Statement stmt;
							// System.out.println ("Query ---- >"+query);
							// extraction taille champ dans la base
							try {
								stmt = con.createStatement();
								ResultSet rs = stmt.executeQuery(query);
								ResultSetMetaData rsmd = rs.getMetaData();
								int numberOfColumns = rsmd.getColumnCount();
								int rowCount = 1;
								while (rs.next()) {
									// System.out.println("Row " + rowCount +
									// ":  ");
									for (int i = 1; i <= numberOfColumns; i++) {
										// System.out.print("   Column " + i +
										// ":  ");
										// System.out.println(rs.getString(i));
										if (i == 1 && !rs.getString(i).contains("Y")) {
											erreur = erreur + "    - " + block.getName() + "." + itm.getName() + "\n";
										}
									}
								}
								stmt.close();
							} catch (SQLException ex) {
								System.err.print("SQLException: ");
								System.err.println(ex.getMessage());
							}
						} // if (!table.isEmpty() && i
					} // fin while block

				} // fin connexion
			} catch (Exception Ecx) {
				System.out.println("Erreur Connexion :   " + Ecx.getMessage());

			}
		}// fin if Env

		return (erreur);
	}

	public String Cles_Modifiable(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.getItemType() == 9 && itm.isPrimaryKey() && itm.getDataType() == 0 && itm.isUpdateAllowed()) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String IE_CLEAR_ALL_MASTER_DETAILS(String fmb, String Nom, String Env) throws IOException,
			ClassNotFoundException, InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		String erreur = "";
		ProgramUnit progunit;
		for (JdapiIterator progunits = grille.getProgramUnits(); progunits.hasNext();) {
			progunit = (ProgramUnit) progunits.next();
			if (progunit.getName().contains("CLEAR_ALL_MASTER_DETAILS")
					&& !progunit.getProgramUnitText().toUpperCase().contains("IE_CLEAR_ALL_MASTER_DETAILS")) {
				erreur = ".";
			}
		}
		return (erreur);
	}

	public String Pre_Block(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		boolean trouve;
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			JdapiIterator triggers = block.getTriggers();
			trouve = false;
			while (triggers.hasNext()) {
				Trigger trigger = (Trigger) triggers.next();
				if (trigger.getName().contains("PRE-BLOCK")) {
					trouve = true;
				}
			}
			if (!block.getName().equals("FOOTER") && !block.getName().equals("TOOLBAR")
					&& !block.getName().equals("TITRE_CTRL") && !block.getName().equals("PAGE_CTRL")
					&& !block.getName().equals("DICREF") && !trouve) {
				{
					erreur = erreur + "     - " + block.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Pre_Block1(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";

		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			JdapiIterator triggers = block.getTriggers();

			while (triggers.hasNext()) {
				Trigger trigger = (Trigger) triggers.next();

				if (trigger.getName().equals("PRE-BLOCK")
						&& !block.getName().equals("FOOTER")
						&& !block.getName().equals("TOOLBAR")
						&& !block.getName().equals("TITRE_CTRL")
						&& !block.getName().equals("DICREF")
						&& !block.getName().equals("PAGE_CTRL")
						&& (!trigger.getTriggerText().toUpperCase().contains(":GLOBAL.DBG_RECHERCHE_POSSIBLE") || !trigger
								.getTriggerText().toUpperCase().contains(":GLOBAL.DBG_DONNEES_BLOC_OBLIG"))) {

					erreur = erreur + "     - " + block.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String PB_SPE003(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException, SQLException {
		String erreur = "";
		String USERNAME = new String("ops$ingenetudes");
		String PASSWORD = new String("galene");
		String ENV = new String("jdbc:oracle:thin:@phobos:1521:" + Env);
		Connection con = null;
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		try {
			DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
			con = DriverManager.getConnection(ENV, USERNAME, PASSWORD);
			System.out.println("Connexion etablie");
		} catch (Exception Ecx) {
			System.out.println("Erreur Connexion :   " + Ecx.getMessage());

		}
		boolean trouve;
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				trouve = false;
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getItemType() == 7
						&& block.getName().equals("PAGE_CTRL")) {
					// recherche dans la base
					String query = "SELECT nvl(PRG_FLDNAME,\'XXX\') FROM ETD_PRP_GLS where PRG_BLKNAME = \'LABEL\' and PRG_FLDNAME = "
							+ "\'" + itm.getName() + "\'";
					Statement stmt;
					// System.out.println ("Query ---- >"+query);
					// extraction taille champ dans la base
					try {
						stmt = con.createStatement();
						ResultSet rs = stmt.executeQuery(query);
						ResultSetMetaData rsmd = rs.getMetaData();
						int numberOfColumns = rsmd.getColumnCount();
						int rowCount = 1;
						while (rs.next()) {
							if (rs.getString(1).contentEquals(itm.getName())) {
								trouve = true;
							}
							rowCount++;
						}
						if (!trouve) {
							// System.err.println("Trouve "+trouve+" item "+block.getName()+"."+itm.getName());
							erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
						}
						stmt.close();
					} catch (SQLException ex) {
						System.err.print("SQLException: ");
						System.err.println(ex.getMessage());
						trouve = false;
					}

				} // if

			} // fin JdapiIterator items = block.getItems(); items.hasNext();)

		}// fin while(blocks.hasNext()
		con.close();
		return (erreur);
	}// fin String testprog

	public String Date_Montant_AFF(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		String verif = "";
		boolean trouve = false;
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getName().endsWith("_AFF")) {
					verif = verif + block.getName() + "." + itm.getName() + ",";
				}
			}
		}
		// Vérification du champ correspondant
		StringTokenizer x = new StringTokenizer(verif, ",");
		String champ_AFF;
		while (x.hasMoreTokens()) {
			champ_AFF = x.nextToken();
			trouve = false;
			// System.err.println("Affiche "+champ_AFF);
			JdapiIterator blocks1 = grille.getBlocks();
			while (blocks1.hasNext()) {
				Block block1 = (Block) blocks1.next();
				for (JdapiIterator items1 = block1.getItems(); items1.hasNext();) {
					Item itm = (Item) items1.next();
					if ((block1.getName().endsWith("_AFF") || block1.getName().endsWith("_AFF_MR"))
							&& (block1.getName() + "." + itm.getName()).equals(champ_AFF.substring(0,
									champ_AFF.indexOf("_AFF"))))

					{
						trouve = true;
					}
				}
			}
			if (trouve = false && !verif.isEmpty()) {
				erreur = erreur + "     - " + champ_AFF + "\n";
			}
		}

		return (erreur);

	}

	public String IE_GEN_INIT_MD_GLOBALES(String fmb, String Nom, String Env) throws IOException,
			ClassNotFoundException, InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		ProgramUnit progunit;
		String plsql = null;
		String verif = "";
		for (JdapiIterator progunits = grille.getProgramUnits(); progunits.hasNext();) {
			progunit = (ProgramUnit) progunits.next();
			if (progunit.getName().contains("IE_GEN_INIT_MD_GLOBALES")) {
				plsql = progunit.getProgramUnitText();
			}
		}
		String verif_D = null;
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible()
						&& !itm.getCanvasName().isEmpty()
						&& itm.getName().endsWith("_AFF")
						&& itm.isSubclassed()
						&& (itm.getSubclassParent().getName().contains("IESO$DATE") || itm.getSubclassParent()
								.getName().contains("IESO$MONTANT"))) {
					if (itm.getSubclassParent().getName().contains("IESO$DATE")) {
						verif = verif + ":GLOBAL." + block.getName() + "_" + itm.getName() + ":='D';";
						verif_D = verif_D + "ERASE('GLOBAL." + block.getName() + "_" + itm.getName() + "');";
					}
					if (itm.getSubclassParent().getName().contains("IESO$MONTANT")) {
						verif = verif + ":GLOBAL." + block.getName() + "_" + itm.getName() + ":='M';";
						verif_D = verif_D + "ERASE('GLOBAL." + block.getName() + "_" + itm.getName() + "');";
					}

				}
			}
		}
		// *************
		StringTokenizer ligne = new StringTokenizer(verif, ";");
		String ligne_md = "";
		String ligne_i = "";
		String ligne_ii = "";
		boolean trouve = false;
		String PLSQL;
		String PLSQL_D;
		// System.err.println("verif--->"+verif);
		while (ligne.hasMoreTokens()) {
			ligne_i = ligne.nextToken();
			ligne_md = ligne_i.toUpperCase().replace(" ", "");
			trouve = false;
			PLSQL = plsql.toUpperCase().substring(plsql.toUpperCase().indexOf("BEGIN") + 5);
			if (PLSQL != "") {
				StringTokenizer ligne_plsql = new StringTokenizer(PLSQL, ";");
				while (ligne_plsql.hasMoreTokens()) {
					ligne_ii = ligne_plsql.nextToken();
					ligne_ii = ligne_ii.replaceAll(" ", "").replaceAll("\b", "").replaceAll("\r", "")
							.replaceAll("\t", "").replaceAll("\n", "")
							+ ";";
					if (ligne_ii.contains(":GLOBAL.")) {
						int i = ligne_ii.indexOf(":GLOBAL.");
						int j = ligne_ii.indexOf(";");
						if (i < j) {
							if (ligne_ii.substring(i, j).contains(ligne_md)) {
								trouve = true;
							}
						}
					}
				}
				if (!trouve) {
					erreur = erreur + "     - " + ligne_md + "\n";
				}
			}
		}

		return (erreur);
	}

	public String IE_GEN_ERASE_MD_GLOBALES(String fmb, String Nom, String Env) throws IOException,
			ClassNotFoundException, InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		ProgramUnit progunit;
		String plsql = "";
		String verif = "";
		String plsql_D = "";
		for (JdapiIterator progunits = grille.getProgramUnits(); progunits.hasNext();) {
			progunit = (ProgramUnit) progunits.next();
			if (progunit.getName().contains("IE_GEN_INIT_MD_GLOBALES")) {
				plsql = progunit.getProgramUnitText();
			}
			if (progunit.getName().contains("IE_GEN_ERASE_MD_GLOBALES")) {
				plsql_D = progunit.getProgramUnitText();
			}
		}

		String verif_D = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible()
						&& !itm.getCanvasName().isEmpty()
						&& itm.getName().endsWith("_AFF")
						&& itm.isSubclassed()
						&& (itm.getSubclassParent().getName().contains("IESO$DATE") || itm.getSubclassParent()
								.getName().contains("IESO$MONTANT"))) {
					if (itm.getSubclassParent().getName().contains("IESO$DATE")) {
						verif = verif + ":GLOBAL." + block.getName() + "_" + itm.getName() + ":='D';";
						verif_D = verif_D + "ERASE('GLOBAL." + block.getName() + "_" + itm.getName() + "');";
					}
					if (itm.getSubclassParent().getName().contains("IESO$MONTANT")) {
						verif = verif + ":GLOBAL." + block.getName() + "_" + itm.getName() + ":='M';";
						verif_D = verif_D + "ERASE('GLOBAL." + block.getName() + "_" + itm.getName() + "');";
					}

				}
			}
		}
		boolean trouve = false;
		StringTokenizer ligne_D = new StringTokenizer(verif_D, ";");
		String ligne_md_D = "";
		String ligne_i_D = "";
		String ligne_ii_D = "";
		String PLSQL_D = "";

		// System.err.println("verif--->"+verif);
		while (ligne_D.hasMoreTokens()) {
			ligne_i_D = ligne_D.nextToken();
			ligne_md_D = ligne_i_D.toUpperCase().replace(" ", "");
			// if (!plsql.toUpperCase().replaceAll(" ", "").contains(ligne_md)){
			trouve = false;
			PLSQL_D = plsql_D.toUpperCase().substring(plsql_D.toUpperCase().indexOf("BEGIN") + 5);
			if (PLSQL_D != "") {
				StringTokenizer ligne_plsql_D = new StringTokenizer(PLSQL_D, ";");
				while (ligne_plsql_D.hasMoreTokens()) {
					ligne_ii_D = ligne_plsql_D.nextToken();
					ligne_ii_D = ligne_ii_D.replaceAll(" ", "").replaceAll("\b", "").replaceAll("\r", "")
							.replaceAll("\t", "").replaceAll("\n", "")
							+ ";";
					if (ligne_ii_D.contains("ERASE")) {
						int i_D = ligne_ii_D.indexOf("ERASE");
						int j_D = ligne_ii_D.indexOf(";");
						if (i_D < j_D) {
							if (ligne_ii_D.substring(i_D, j_D).contains(ligne_md_D)) {
								trouve = true;
							}
						}
					}
				}
				if (!trouve) {
					// System.out.println("plsql " + PLSQL_D);
					// System.out.println("ligne_md_D " + ligne_md_D);
					erreur = erreur + "     - Manque ( " + ligne_md_D + " ) dans IE_GEN_ERASE_MD_GLOBALES" + "\n";
				}
			}
		}

		return (erreur);
	}

	public String Prompt(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && !itm.getPrompt().isEmpty()
						&& !itm.getPrompt().startsWith("#")) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	// ******** encours****
	public String Lov_Lib_Codif(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		String erreur = "";
		LOV lov;
		LOVColumnMapping y;
		for (JdapiIterator lovs = grille.getLOVs(); lovs.hasNext();) {
			lov = (LOV) lovs.next();
			for (JdapiIterator x = lov.getLOVColumnMappings(); x.hasNext();) {
				y = (LOVColumnMapping) x.next();
				y.getReturnItem();
				System.err.println("LOV -->" + lov.getName() + "Return item -->" + y.getReturnItem());
			}

		}
		return (erreur);
	}

	// //******************

	public String Codif_Uppercase(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getName().startsWith("C_")
						&& itm.getCaseRestriction() != 1) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Cles_Uppercase(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.getItemType() == 9 && itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.isPrimaryKey()
						&& itm.getDataType() == 0 && itm.getCaseRestriction() != 1) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String IE_GEN_INIT_DBG_GLOBALES(String fmb, String Nom, String Env) throws IOException,
			ClassNotFoundException, InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		String erreur = "";
		String plsql = "";
		ProgramUnit progunit;
		for (JdapiIterator progunits = grille.getProgramUnits(); progunits.hasNext();) {
			progunit = (ProgramUnit) progunits.next();
			if (progunit.getName().contains("IE_GEN_INIT_DBG_GLOBALES")) {
				plsql = progunit.getProgramUnitText();
				if (!plsql.toUpperCase().replaceAll(" ", "").contains("GLOBAL.DBG_ORIGINE:='FORMS5'")) {
					erreur = erreur + "GLOBAL.DBG_ORIGINE := 'FORMS5' " + "\n";
				}
				if (!plsql.toUpperCase().replaceAll(" ", "").contains(":GLOBAL.CGU_DATE_PHYSIQUE")) {
					erreur = erreur + "- :GLOBAL.CGU_DATE_PHYSIQUE" + "\n";
				}
				if (!plsql.toUpperCase().replaceAll(" ", "").contains(":GLOBAL.DBG_PREMIER_BLOC_NAV")) {
					erreur = erreur + "- :GLOBAL.DBG_PREMIER_BLOC_NAV" + "\n";
				}
				if (!plsql.toUpperCase().replaceAll(" ", "").contains(":GLOBAL.DBG_PREMIER_BLOC_NAV")) {
					erreur = erreur + "- :GLOBAL.DBG_DERNIER_BLOC_NAV" + "\n";
				}

			}
		}
		return (erreur);
	}

	public String Libelle_MAJ(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getItemType() == 9
						&& itm.getName().toUpperCase().startsWith("LIB") && itm.getCaseRestriction() == 1) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Libelle_Recherche(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && itm.getItemType() == 9
						&& itm.getName().toUpperCase().startsWith("LIB") && itm.isQueryAllowed()) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Nouveaux_Blocks(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		boolean trouve;
		String trig;
		String old_block = null;
		int n = 0;
		while (blocks.hasNext()) {

			Block block = (Block) blocks.next();
			old_block = block.getName();
			n = n + 1;
			if ((n == 6 && old_block.toUpperCase().contains("TITRE_CTRL"))
					|| (n < 5 && !block.getName().toUpperCase().contains("TOOLBAR")
							&& !block.getName().toUpperCase().contains("FOOTER")
							&& !block.getName().toUpperCase().contains("DICREF") && !block.getName().toUpperCase()
							.contains("PAGE_CTRL")))

			{
				erreur = erreur + "     - " + block.getName() + "\n";

			}

		}
		return (erreur);
	}

	public String Validate_From_List(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && itm.isValidateFromList()) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Tab_Bevel(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		String erreur = "";
		try {
			FormModule grille = FormModule.open(fmb);
			Canvas cnv;
			for (JdapiIterator cnvss = grille.getCanvases(); cnvss.hasNext();) {
				cnv = (Canvas) cnvss.next();
				if (cnv.getCanvasType() == 4 && cnv.getBevel() != 2) {
					erreur = erreur + "     - " + cnv.getName() + "\n";
				}
			}
		} catch (Throwable e) {
			System.err.println("erreur Lancement Nom_Canevas" + e);
		}
		return (erreur);
	}

	public String Block_interrogeable(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && block.isQueryAllowed()
						&& !itm.isQueryAllowed()) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	public String Y_Position_Frame(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		String erreur = "";
		String First_Block = "";
		int n = 0;

		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			n = n + 1;
			if (n == 6) {
				First_Block = block.getName();
			}
		}

		try {

			Canvas cnv;
			Graphics grph;
			n = 1;
			for (JdapiIterator cnvss = grille.getCanvases(); cnvss.hasNext();) {
				cnv = (Canvas) cnvss.next();
				for (JdapiIterator grphs = cnv.getGraphicses(); grphs.hasNext();) {
					grph = (Graphics) grphs.next();
					if (!grph.getName().equals("GRPH_" + First_Block) && grph.getYPosition() != 12 && n == 1) {
						erreur = erreur + "     - " + grph.getName() + "\n";
					}
				}
			}
		} catch (Throwable e) {
			System.err.println("erreur Lancement Nom_Frames" + e);
		}
		return (erreur);
	}

	public String X_Position_Titre_Block(String fmb, String Nom, String Env) throws IOException,
			ClassNotFoundException, InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";

		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			if (block.getName().toUpperCase().equals("TITRE_CTRL")) {
				for (JdapiIterator items = block.getItems(); items.hasNext();) {
					Item itm = (Item) items.next();
					if (!itm.getName().toUpperCase().endsWith("_WIN") && !itm.getName().toUpperCase().endsWith("_TAB")
							&& itm.getName().toUpperCase().contains("_TITRE")) {
						// nom block a rechercher
						String recherche = itm.getName().substring(0, itm.getName().toUpperCase().indexOf("_TITRE"));
						boolean trouve = false;
						// ********
						try {
							Canvas cnv;
							Graphics grph;
							for (JdapiIterator cnvss = grille.getCanvases(); cnvss.hasNext();) {
								cnv = (Canvas) cnvss.next();
								for (JdapiIterator grphs = cnv.getGraphicses(); grphs.hasNext();) {
									grph = (Graphics) grphs.next();
									if (!grph.getName().equals("GRPH_" + recherche) && itm.getXPosition() != 15
											&& itm.getYPosition() != grph.getYPosition() + 5) {
										erreur = erreur + "     - " + itm.getName() + "\n";
									}
								}
							}
						} catch (Throwable e) {
							System.err.println("erreur Lancement Nom_Frames" + e);
						}
						// *******

					}
				}
			}
		}
		return (erreur);
	}

	public String Titre_colonne_Lov(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		String erreur = "";
		boolean propriete;
		LOV lov;
		LOVColumnMapping y;
		boolean titre;
		for (JdapiIterator lovs = grille.getLOVs(); lovs.hasNext();) {
			lov = (LOV) lovs.next();
			// verification des proprietes
			propriete = false;
			if (lov.getWidth() != 250 || lov.getHeight() != 180 || !lov.getTitle().contains("EKIP - LOV")
					|| !lov.getBackColor().contains("r88g88b75") || !lov.getForegroundColor().contains("black")
					|| !lov.getFillPattern().contains("transparent") || !lov.getFontName().contains("MS Sans Serif")
					|| lov.getFontSize() != 800) {
				propriete = true;
			}
			// *********
			titre = false;
			for (JdapiIterator x = lov.getLOVColumnMappings(); x.hasNext();) {
				y = (LOVColumnMapping) x.next();
				if (!y.getTitle().isEmpty()) {
					titre = true;
				}
			}
			if (titre || propriete) {
				erreur = erreur + "     - " + lov.getName() + "\n";
			}
		}
		return (erreur);
	}

	public String Enabled_False(String fmb, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		FormModule grille = FormModule.open(fmb);
		JdapiIterator blocks = grille.getBlocks();
		String erreur = "";
		while (blocks.hasNext()) {
			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {
				Item itm = (Item) items.next();
				if (itm.isVisible() && !itm.getCanvasName().isEmpty() && !itm.isEnabled()
						&& (block.getSubclassParent().getName().endsWith("_MR") || itm.getName().endsWith("_AFF"))) {
					erreur = erreur + "     - " + block.getName() + "." + itm.getName() + "\n";
				}
			}
		}
		return (erreur);
	}

	// ************* Script MCD *************************
	public String Nom_Script_MCD(String mcd, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		String erreur = "";
		if (!Nom.substring(0, 13).equals("CREATE_TABLE_")
				|| !Nom.substring(0, Nom.indexOf(".")).toUpperCase().equals(Nom.substring(0, Nom.indexOf(".")))) {

			erreur = ".";
		}
		return (erreur);
	}

	public String Propietaire_Ekip(String mcd, String Nom, String Env) throws IOException, ClassNotFoundException,
			InstantiationException, IllegalAccessException {
		String erreur = "";
		try {
			InputStream ips = new FileInputStream(mcd);
			InputStreamReader ipsr = new InputStreamReader(ips);
			BufferedReader br = new BufferedReader(ipsr);
			String ligne;
			while ((ligne = br.readLine()) != null) {
				if (ligne.toUpperCase().contains("OWNER") && !ligne.toUpperCase().contains("'OPS$INGENETUDES'")) {
					// System.out.println(ligne);
					erreur = ".";
				}
			}
			br.close();
		} catch (Exception e) {
			System.out.println(e.toString());
		}
		return (erreur);
	}

	// ************* Procédures Basées *******************
	public String Mode_Trace_Variables(String P_Base, String Nom, String Env) throws IOException,
			ClassNotFoundException, InstantiationException, IllegalAccessException {
		String erreur = "";
		try {
			InputStream ips = new FileInputStream(P_Base);
			InputStreamReader ipsr = new InputStreamReader(ips);
			BufferedReader br = new BufferedReader(ipsr);
			String ligne;
			// String dec_v1 =
			// "w_version           PKG_TRACE.VERSION%TYPE     ;";
			int t_dec_v1 = 0;
			// String dec_v2 = "w_tab_contexte  PKG_TRACE.TAB_CONTEXTE    ;";
			int t_dec_v2 = 0;
			// String dec_v3 = "w_nomprog         PKG_TRACE.NOMPROG%TYPE  ;";
			int t_dec_v3 = 0;
			while ((ligne = br.readLine()) != null) {

				if (ligne.toUpperCase().replaceAll(" ", "").contains("W_VERSIONPKG_TRACE.VERSION%TYPE;")) {
					t_dec_v1 = 1;

				}
				if (ligne.toUpperCase().replaceAll(" ", "").contains("W_TAB_CONTEXTEPKG_TRACE.TAB_CONTEXTE;")) {
					t_dec_v2 = 1;
				}
				if (ligne.toUpperCase().replaceAll(" ", "").contains("W_NOMPROGPKG_TRACE.NOMPROG%TYPE;")) {
					t_dec_v3 = 1;
				}
			}
			if (t_dec_v1 == 0) {
				erreur = erreur + "w_version" + ", ";
			}
			if (t_dec_v2 == 0) {
				erreur = erreur + "w_tab_contexte" + ", ";
			}
			if (t_dec_v3 == 0) {
				erreur = erreur + "w_nomprog" + " ";
			}
			br.close();
		} catch (Exception e) {
			System.out.println(e.toString());
		}
		return (erreur);
	}

	public String Mode_Trace_Dmessage(String P_Base, String Nom, String Env) throws IOException,
			ClassNotFoundException, InstantiationException, IllegalAccessException {
		String erreur = "";
		try {
			InputStream ips = new FileInputStream(P_Base);
			InputStreamReader ipsr = new InputStreamReader(ips);
			BufferedReader br = new BufferedReader(ipsr);
			String ligne;
			int dmessage = 0;
			while ((ligne = br.readLine()) != null) {

				if (ligne.toUpperCase().replaceAll(" ", "").contains("DB_UTADM_ERREUR_OTHERS")
						&& (ligne.toUpperCase().replaceAll(" ", "").contains("W_VERSION"))) {
					dmessage = 1;
				}
			}
			erreur = ".";
			br.close();
		} catch (Exception e) {
			System.out.println(e.toString());
		}
		return (erreur);
	}

	public String Mode_Trace_IE_VERSION(String P_Base, String Nom, String Env) throws IOException,
			ClassNotFoundException, InstantiationException, IllegalAccessException {
		String erreur = "";

		try {
			InputStream ips = new FileInputStream(P_Base);
			InputStreamReader ipsr = new InputStreamReader(ips);
			BufferedReader br = new BufferedReader(ipsr);
			String ligne;
			String lligne = "";
			int dmessage = 0;
			boolean trouve = false;
			while ((ligne = br.readLine()) != null) {

				if (ligne.toUpperCase().replaceAll(" ", "").contains("CREATEORREPLACE") && !trouve) {
					lligne = ligne;
					trouve = true;
				}
			}
			erreur = ".";
			br.close();
		} catch (Exception e) {
			System.out.println(e.toString());
		}
		return (erreur);
	}
}// fin GrilleServices

